<?php

/**
 * Subclass for representing a row from the 'product' table.
 *
 * 
 *
 * @package lib.model
 */ 
class Product extends BaseProduct
{
  function Product(){
  	$this->setIden('');
  	$this->setProductName('');
  	$this->setProductType(sfConfig::get('app_product_default_type'));
  	$this->setProductStatus(sfConfig::get('app_product_default_status'));
  	$this->setProductSize('');
  	$this->setColorCode('');
  	$this->setColorName('');
  	$this->setArticleCode('');
  	$this->setSupplierIden('');
  	$this->setProductUnit('');
  	$this->setProductPackageUnit('');
  	$this->setReorderQuantity(0);
  	$this->setRemarks('');
  }
  
  function getFullName(){
  	$data = '';
  	foreach($this->getProductCategoryProducts() as $product_category_product){
      $data .= $product_category_product->getProductCategory()->getName().' ';
  	}
  	$data .= $this->getProductName();
  	return $data;
  }
  
  function getSupplierName(){
  	return $this->getAccountSupplier()->getContact()->getCompanyName();
  }
  
  function getProductCategoryProductsOrderByLevelNumber(){
  	$c = new Criteria();
  	$c->addJoin(ProductCategoryPeer::IDEN,ProductCategoryProductPeer::CATEGORY_IDEN);
  	$c->addAscendingOrderByColumn(ProductCategoryPeer::LEVEL_NUMBER);
  	return $this->getProductCategoryProducts($c);
  }
  
}
